public class Offer15 {
    public int hammingWeight(int n) {
        int res=0;
        for (int i = 0; i < 32; i++) {
            if(((1<<i)|n)==n){
                ++res;
            }
        }
        return res;
    }
}
